package com.mc2.docapp.disabilityassessmenttool.SpinalAffection;

import io.realm.RealmObject;
import io.realm.annotations.PrimaryKey;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class C_neurological_deficit extends RealmObject {
    @PrimaryKey
    public int id;
    private double motor;
    private double sensory;
    private double bladdar;
    private double ataxia;
    private double totalNeuroDeficit;

    public void calc(C_neurological_deficit dt) {

        double a = dt.getMotor();//transverse.getActual_left();
        double b = dt.getSensory();//transverse.getActual_right();
        double c = dt.getBladdar();//clubfoot.getActual_left();
        double d = dt.getAtaxia();//clubfoot.getActual_right();
        double step1;
        double step2;
        double step3;

        step1 = calByFormula(a,b);
        step2 = calByFormula(step1,c);
        step3 = calByFormula(step2,d);

        dt.setTotalNeuroDeficit(step3);

    }

    private double calByFormula(double a, double b) {
        if(a<b){
            a = a + b;
            b = a - b;
            a = a - b;
        }
        if(a > 90d) {
            return a;
        }
        double c = a + (((90 - a) * b) / 90.0);
        return c;
    }





    public C_neurological_deficit strip(C_neurological_deficit dt) {
        return new C_neurological_deficit(dt.getId(), dt.getMotor(),dt.getSensory(), dt.getBladdar(),dt.getAtaxia(), dt.getTotalNeuroDeficit());
    }

}
